package mcchristian;

import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.interceptor.ServletRequestAware;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class News_Action extends ActionSupport implements ServletRequestAware {

	private List<News> newses = new ArrayList<News>();
	private String message;
	private HttpServletRequest request; 
	
	public String execute() throws Exception  
    {   
		Map session = ActionContext.getContext().getSession();
		Excel_Function excel_function = new Excel_Function();
		if ((String)session.get("rootpath") == null){
			return "INDEX";  
		}	
		String excelPath = (String)session.get("rootpath") + "db\\news.xls";
		newses = excel_function.contentNewsReading(excelPath);
        return SUCCESS;  
    }

	public void setServletRequest(HttpServletRequest request) { 
        this.request = request; 
    } 
	
	public List<News> getNewses() {
		return newses;
	}

	public void setNewses(List<News> newses) {
		this.newses = newses;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}
	
}
